<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品详情</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            --warning-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
            --danger-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
            --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
            --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.07);
            --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.1);
            --shadow-heavy: 0 15px 35px rgba(0, 0, 0, 0.1);
            --border-radius: 20px;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        * {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            padding-top: 5rem; /* 为固定的导航栏留出空间 */
        }

        /* 导航栏样式 */
        .navbar {
            background: rgba(255, 255, 255, 0.95) !important;
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            box-shadow: var(--shadow-light);
        }

        .navbar-brand {
            font-weight: 700;
            font-size: 1.5rem;
            background: var(--primary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .nav-link {
            font-weight: 500;
            transition: var(--transition);
            position: relative;
        }

        .nav-link:hover {
            transform: translateY(-2px);
        }

        /* 商品信息区域样式 */
        .hero-section {
            background: var(--primary-gradient);
            color: white;
            padding: 3rem 0;
            margin-bottom: 3rem;
            position: relative;
            overflow: hidden;
        }

        .hero-section::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
            opacity: 0.3;
        }

        .hero-content {
            position: relative;
            z-index: 2;
        }

        .model-badge {
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.3);
            border-radius: 50px;
            padding: 0.5rem 1.5rem;
            font-weight: 600;
            font-size: 0.9rem;
        }

        /* 卡片样式 */
        .card {
            border: none;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow-light);
            transition: var(--transition);
            overflow: hidden;
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            margin-bottom: 2rem;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: var(--shadow-heavy);
        }

        .card-header {
            background: var(--primary-gradient);
            color: white;
            border: none;
            padding: 1.5rem;
            font-weight: 600;
        }

        .card-body {
            padding: 2rem;
        }

        /* 预测表单样式 */
        .prediction-form {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            border-radius: var(--border-radius);
            padding: 2.5rem;
            border: 2px solid transparent;
            transition: var(--transition);
        }

        .prediction-form:hover {
            border-color: #667eea;
            background: linear-gradient(135deg, #f0f4ff 0%, #e6f0ff 100%);
        }

        .form-control {
            border-radius: 15px;
            border: 2px solid #e9ecef;
            padding: 12px 20px;
            font-weight: 500;
            transition: var(--transition);
        }

        .form-control:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
        }

        .form-label {
            font-weight: 600;
            color: #495057;
            margin-bottom: 0.5rem;
        }

        /* 按钮样式 */
        .btn {
            border-radius: 50px;
            padding: 15px 40px;
            font-weight: 600;
            transition: var(--transition);
            border: none;
            position: relative;
            overflow: hidden;
        }

        .btn-primary {
            background: var(--primary-gradient);
            box-shadow: var(--shadow-light);
        }

        .btn-primary:hover {
            transform: translateY(-3px);
            box-shadow: var(--shadow-medium);
        }

        .btn-primary::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: left 0.5s;
        }

        .btn-primary:hover::before {
            left: 100%;
        }

        /* 结果卡片样式 */
        .results-card {
            border: none;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow-medium);
            overflow: hidden;
        }

        .summary-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .summary-card {
            background: var(--primary-gradient);
            color: white;
            border-radius: var(--border-radius);
            padding: 1.5rem;
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .summary-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
            transform: translateX(-100%);
            transition: transform 0.6s;
        }

        .summary-card:hover::before {
            transform: translateX(100%);
        }

        .summary-card.success {
            background: var(--success-gradient);
        }

        .summary-card.warning {
            background: var(--warning-gradient);
        }

        .summary-card.info {
            background: var(--secondary-gradient);
        }

        .summary-value {
            font-size: 2.5rem;
            font-weight: 800;
            margin-bottom: 0.5rem;
        }

        .summary-label {
            font-size: 0.9rem;
            opacity: 0.9;
        }

        /* 表格样式 */
        .table {
            margin-bottom: 0;
        }

        .table thead th {
            background: var(--dark-gradient);
            color: white;
            border: none;
            font-weight: 600;
            padding: 1.2rem 1rem;
        }

        .table tbody tr {
            transition: var(--transition);
        }

        .table tbody tr:hover {
            background: rgba(102, 126, 234, 0.05);
            transform: scale(1.01);
        }

        .table tbody td {
            padding: 1rem;
            border: none;
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        }

        /* 状态徽章样式 */
        .status-badge {
            font-size: 0.8rem;
            padding: 0.5rem 1rem;
            border-radius: 20px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .status-adequate {
            background: var(--success-gradient);
            color: white;
        }

        .status-tight {
            background: var(--warning-gradient);
            color: white;
        }

        .status-out {
            background: var(--danger-gradient);
            color: white;
        }

        /* 警告样式 */
        .alert {
            border-radius: var(--border-radius);
            border: none;
            padding: 1.5rem;
            font-weight: 500;
        }

        /* 模型信息样式 */
        .model-info {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: var(--border-radius);
            padding: 2rem;
            position: relative;
            overflow: hidden;
        }

        .model-info::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
            opacity: 0.3;
        }

        .model-info-content {
            position: relative;
            z-index: 2;
        }

        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .fade-in-up {
            animation: fadeInUp 0.6s ease-out;
        }

        .fade-in-up-delay-1 {
            animation: fadeInUp 0.6s ease-out 0.1s both;
        }

        .fade-in-up-delay-2 {
            animation: fadeInUp 0.6s ease-out 0.2s both;
        }

        .fade-in-up-delay-3 {
            animation: fadeInUp 0.6s ease-out 0.3s both;
        }

        /* 页脚样式 */
        footer {
            background: var(--dark-gradient);
            color: white;
            padding: 2rem 0;
            margin-top: 4rem;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .summary-grid {
                grid-template-columns: 1fr;
            }
            
            .card-body {
                padding: 1.5rem;
            }
            
            .prediction-form {
                padding: 1.5rem;
            }
        }

        /* 加载动画 */
        .loading-spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 1s ease-in-out infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* 商品信息网格 */
        .product-info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1rem;
        }

        .info-item {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 1rem;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .info-label {
            font-size: 0.8rem;
            opacity: 0.8;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 0.5rem;
        }

        .info-value {
            font-weight: 600;
            font-size: 1.1rem;
        }

        /* 新增样式: 优化详情页布局 */
        .details-grid {
            display: grid;
            grid-template-columns: 300px 1fr;
            gap: 2rem;
            align-items: start;
        }

        .main-info-card, .kpi-card, .extra-info-card {
            background: rgba(255, 255, 255, 0.9);
            border-radius: var(--border-radius);
            padding: 1.5rem;
            box-shadow: var(--shadow-light);
            backdrop-filter: blur(10px);
        }

        .main-info-card h4 {
            font-weight: 700;
            margin-bottom: 0.25rem;
        }

        .main-info-card .text-muted {
            font-size: 0.9rem;
        }

        .info-pills {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            margin-top: 1rem;
        }

        .info-pills .badge {
            font-size: 0.8rem;
            padding: 0.5em 0.9em;
        }

        .kpi-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 1rem;
        }

        .kpi-item {
            text-align: center;
            padding: 1rem;
            background: rgba(102, 126, 234, 0.05);
            border-radius: 15px;
        }

        .kpi-value {
            font-size: 2rem;
            font-weight: 700;
            color: #667eea;
        }

        .kpi-label {
            font-size: 0.85rem;
            font-weight: 500;
            color: #555;
        }

        .extra-info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1.5rem;
        }

        .extra-info-item {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .extra-info-item .icon {
            font-size: 1.5rem;
            color: #764ba2;
            min-width: 40px;
            height: 40px;
            background: rgba(118, 75, 162, 0.1);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .extra-info-item .info-label {
            font-size: 0.9rem;
            color: #6c757d;
            margin-bottom: 0;
        }
        .extra-info-item .info-value {
            font-size: 1.2rem;
            font-weight: 600;
        }
        /* 上升期背景色 */
        .phase-badge-rising-phase {
            background-color: rgba(78, 115, 223, 0.1);
        }

        /* 爆发期背景色 */
        .phase-badge-peak-phase {
            background-color: rgba(28, 200, 138, 0.1);
        }

        /* 衰退期背景色 */
        .phase-badge-decline-phase {
            background-color: rgba(246, 194, 62, 0.1);
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light fixed-top">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('index') }}">
                <i class="fas fa-chart-line me-2"></i>AI库存预测
            </a>
            <div class="navbar-nav ms-auto">
                <a class="nav-link" href="{{ url_for('product_data_manage') }}">
                    <i class="fas fa-home me-1"></i>返回上一级
                </a>
{#                <a class="nav-link" href="{{ url_for('manual') }}">#}
{#                    <i class="fas fa-book me-1"></i>使用说明#}
{#                </a>#}
            </div>
        </div>
    </nav>

    <!-- 商品信息区域 -->
    <div class="hero-section">
        <div class="container hero-content">
            <h1 class="display-5 mb-2 fade-in-up">
                <i class="fas fa-box me-3"></i>商品详情分析
            </h1>
            <p class="lead mb-3 fade-in-up-delay-1">深入了解商品表现，做出更精准的库存决策</p>
        </div>
    </div>

    <div class="container" style="margin-top: -80px; position:relative; z-index: 10;">
        <div class="details-grid">
            <!-- 左侧核心信息 -->
            <div class="main-info-card fade-in-up-delay-2">
                <h4>{{ product_info.get('商品名称', 'N/A') }}</h4>
                <p class="text-muted">ID: {{ product_info.get('商品ID', 'N/A') }}</p>
                <div class="info-pills">
                    <span class="badge rounded-pill bg-primary"><i class="fas fa-barcode me-1"></i> {{ product_info.get('货号', 'N/A') }}</span>
                    <span class="badge rounded-pill bg-success"><i class="fas fa-check-circle me-1"></i> {{ product_info.get('商品状态', 'N/A') }}</span>
                    {% if product_info.get('商品标签') %}
                    <span class="badge rounded-pill bg-secondary"><i class="fas fa-tags me-1"></i> {{ product_info.get('商品标签') }}</span>
                    {% endif %}
                </div>
                <hr class="my-3">
                <div class="text-center">
                    {% if has_product_model %}
                        <div class="model-badge" style="display: inline-flex; align-items: center;">
                            <i class="fas fa-robot me-2"></i>商品级别模型
                        </div>
                    {% else %}
                        <div class="model-badge" style="display: inline-flex; align-items: center;">
                            <i class="fas fa-chart-line me-2"></i>聚合模型
                        </div>
                    {% endif %}
                </div>
            </div>

            <!-- 右侧详细信息 -->
            <div class="fade-in-up-delay-3">
                <!-- 关键KPI -->
                <!-- <div class="kpi-card mb-4">
                    <h5 class="mb-3 fw-bold">核心指标</h5>
                    <div class="kpi-grid">
                        <div class="kpi-item">
                            <div class="kpi-value">{{ product_info.get('商品访客数', 0) }}</div>
                            <div class="kpi-label">商品访客数</div>
                        </div>
                        <div class="kpi-item">
                            <div class="kpi-value">{{ "%.2f"|format(product_info.get('支付金额', 0.0) | float) }}</div>
                            <div class="kpi-label">支付金额</div>
                        </div>
                        <div class="kpi-item">
                            <div class="kpi-value">{{ "%.4f"|format(product_info.get('商品支付转化率', 0.0) | float) }}</div>
                            <div class="kpi-label">支付转化率</div>
                        </div>
                        <div class="kpi-item">
                            <div class="kpi-value">{{ "%.4f"|format(product_info.get('下单转化率', 0.0) | float) }}</div>
                            <div class="kpi-label">下单转化率</div>
                        </div>
                    </div>
                </div> -->

                <!-- 其他详细信息 -->
                <!-- <div class="extra-info-card">
                     <h5 class="mb-3 fw-bold">详细数据</h5>
                    <div class="extra-info-grid">
                        {% set standard_keys = ['商品名称', '商品ID', '货号', '商品状态', '商品标签', '商品访客数', '支付金额', '商品支付转化率', '下单转化率'] %}
                        {% set icon_map = {
                            '商品浏览量': 'fa-eye',
                            '平均停留时长': 'fa-clock',
                            '商品收藏人数': 'fa-heart',
                            '商品加购件数': 'fa-cart-plus',
                            '下单买家数': 'fa-user-check',
                            '下单件数': 'fa-box-open',
                            '支付买家数': 'fa-credit-card',
                            '支付件数': 'fa-receipt',
                            '支付金额': 'fa-money-bill-wave',
                            '商品支付转化率': 'fa-percent',
                            '退款金额': 'fa-undo-alt',
                            '老买家支付金额': 'fa-user-tag'
                        } %}
                        {% for key, value in product_info.items() %}
                            {% if key not in standard_keys %}
                            <div class="extra-info-item">
                                <div class="icon">
                                    <i class="fas {{ icon_map.get(key, 'fa-chart-pie') }}"></i>
                                </div>
                                <div>
                                    <div class="info-label">{{ key }}</div>
                                    <div class="info-value">
                                        {% if value is number and value > 1 and '.' in value|string %}
                                            {{ "%.2f"|format(value|float) }}
                                        {% elif value is number and value < 1 and value > 0 %}
                                            {{ "%.4f"|format(value|float) }}
                                        {% else %}
                                            {{ value }}
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                            {% endif %}
                        {% endfor %}
                    </div>
                </div>
            </div> -->
        </div>
    </div>

    <div class="container" style="margin-top: 2rem;">
        <!-- 预测参数设置 -->
        <div class="card fade-in-up-delay-1">
            <div class="card-header">
                <h5 class="mb-0">
                    <i class="fas fa-cogs me-2"></i>预测参数设置
                </h5>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ url_for('predict', item_id=item_id) }}" class="prediction-form">
                    <div class="row">
                        <div class="col-md-3 mb-3">
                            <label for="current_stock" class="form-label">
                                <i class="fas fa-boxes me-1"></i>当前库存
                            </label>
                            <input type="number" class="form-control" id="current_stock" name="current_stock" 
                                   value="{{ results.params.current_stock if results and results.params else 100 }}" 
                                   min="0" required>
                        </div>
                        <div class="col-md-3 mb-3">
                            <label for="days_to_predict" class="form-label">
                                <i class="fas fa-calendar me-1"></i>预测天数
                            </label>
                            <input type="number" class="form-control" id="days_to_predict" name="days_to_predict" 
                                   value="{{ results.params.days_to_predict if results and results.params else 30 }}" 
                                   min="1" max="365" required>
                        </div>
                        <div class="col-md-3 mb-3">
                            <label for="lead_time" class="form-label">
                                <i class="fas fa-clock me-1"></i>补货周期
                            </label>
                            <input type="number" class="form-control" id="lead_time" name="lead_time" 
                                   value="{{ results.params.lead_time if results and results.params else 7 }}" 
                                   min="1" max="30" required>
                        </div>
                        <div class="col-md-3 mb-3">
                            <label for="safety_factor" class="form-label">
                                <i class="fas fa-shield-alt me-1"></i>安全系数
                            </label>
                            <input type="number" class="form-control" id="safety_factor" name="safety_factor" 
                                   value="{{ results.params.safety_factor if results and results.params else 1.2 }}" 
                                   min="1.0" max="3.0" step="0.1" required>
                        </div>
                    </div>
                    <div class="text-center">
                        <button type="submit" class="btn btn-primary btn-lg">
                            <i class="fas fa-magic me-2"></i>开始预测分析
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <!-- 预测结果 -->
        {% if results %}
        <div class="card results-card fade-in-up-delay-2">
            <div class="card-header">
                <h5 class="mb-0">
                    <i class="fas fa-chart-bar me-2"></i>预测结果
                    {% if results.summary.model_type %}
                        <span class="badge bg-info ms-2">{{ results.summary.model_type }}</span>
                    {% endif %}
                </h5>
            </div>
            <div class="card-body">
                <!-- 警告信息 -->
                {% if results.warning %}
                <div class="alert alert-warning alert-dismissible fade show" role="alert">
                    <i class="fas fa-exclamation-triangle me-2"></i>{{ results.warning }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
                {% endif %}

                <!-- 汇总信息 -->
                <div class="summary-grid">
                    <div class="summary-card success">
                        <div class="summary-value">{{ results.summary.total_demand }}</div>
                        <div class="summary-label">总预测需求</div>
                    </div>
                    <div class="summary-card warning">
                        <div class="summary-value">{{ results.summary.total_orders }}</div>
                        <div class="summary-label">建议补货量</div>
                    </div>
                    <div class="summary-card info">
                        <div class="summary-value">{{ results.params.days_to_predict }}</div>
                        <div class="summary-label">预测天数</div>
                    </div>
                    <div class="summary-card">
                        <div class="summary-value">{{ results.params.safety_factor }}</div>
                        <div class="summary-label">安全系数</div>
                    </div>
                </div>

                <!-- 详细预测表格 -->
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>阶段</th>
                                <th>日期</th>
                                <th>预测需求</th>
                                <th>库存前</th>
                                <th>库存后</th>
                                <th>安全库存</th>
                                <th>再订货点</th>
                                <th>状态</th>
                                <th>建议</th>
                                <th>补货量</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for day in results.daily %}
                            <tr>
                                <td>
                                    {% if day.phase == 'rising' %}
                                    <span class="phase-badge-rising-phase">
                                      <i class="fas fa-arrow-up"></i> {{ day.phase_name }}
                                    </span>
                                  {% elif day.phase == 'peak' %}
                                    <span class="phase-badge-peak-phase">
                                      <i class="fas fa-fire"></i> {{ day.phase_name }}
                                    </span>
                                  {% else %}
                                    <span class="phase-badge-decline-phase">
                                      <i class="fas fa-arrow-down"></i> {{ day.phase_name }}
                                    </span>
                                  {% endif %}
                                </td>
                                <td>{{ day.date }}</td>
                                <td>{{ day.predicted_demand }}</td>
                                <td>{{ day.stock_before }}</td>
                                <td>{{ day.stock_after }}</td>
                                <td>{{ day.safety_stock }}</td>
                                <td>{{ day.reorder_point }}</td>
                                <td>
                                    {% if day.status == "库存充足" %}
                                        <span class="status-badge status-adequate">{{ day.status }}</span>
                                    {% elif day.status == "库存紧张" %}
                                        <span class="status-badge status-tight">{{ day.status }}</span>
                                    {% else %}
                                        <span class="status-badge status-out">{{ day.status }}</span>
                                    {% endif %}
                                </td>
                                <td>{{ day.suggestion }}</td>
                                <td>
                                    {% if day.order_qty > 0 %}
                                        <span class="badge bg-primary">{{ day.order_qty }}</span>
                                    {% else %}
                                        <span class="text-muted">0</span>
                                    {% endif %}
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        {% endif %}

        <!-- 模型信息 -->
        <div class="model-info fade-in-up-delay-3">
            <div class="model-info-content">
                <h5 class="mb-3">
                    <i class="fas fa-brain me-2"></i>模型信息
                </h5>
                {% if has_product_model %}
                    <div class="alert alert-success mb-0">
                        <i class="fas fa-check-circle me-2"></i>
                        <strong>商品级别模型已加载</strong><br>
                        此商品使用专门训练的独立模型进行预测，能够更准确地反映该商品的销售模式和趋势。
                    </div>
                {% else %}
                    <div class="alert alert-warning mb-0">
                        <i class="fas fa-exclamation-triangle me-2"></i>
                        <strong>使用聚合模型</strong><br>
                        此商品使用整体销售趋势的聚合模型进行预测。如需更精确的预测，请确保已训练商品级别模型。
                    </div>
                {% endif %}
            </div>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="text-center">
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    <h5><i class="fas fa-code me-2"></i>技术栈</h5>
                    <p class="mb-0">Python • Flask • Prophet • Bootstrap</p>
                </div>
                <div class="col-md-6">
                    <h5><i class="fas fa-chart-line me-2"></i>功能特性</h5>
                    <p class="mb-0">商品级别预测 • 智能库存优化 • 实时分析</p>
                </div>
            </div>
            <hr class="my-4" style="border-color: rgba(255,255,255,0.2);">
            <p class="mb-0">
                <i class="fas fa-heart me-1" style="color: #e74c3c;"></i>
                商品库存预测系统 | 基于机器学习的智能库存管理
            </p>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // 添加滚动效果
        window.addEventListener('scroll', function() {
            const navbar = document.querySelector('.navbar');
            if (window.scrollY > 50) {
                navbar.style.background = 'rgba(255, 255, 255, 0.98)';
            } else {
                navbar.style.background = 'rgba(255, 255, 255, 0.95)';
            }
        });

        // 表单提交动画
        document.querySelector('form').addEventListener('submit', function() {
            const submitBtn = document.querySelector('button[type="submit"]');
            submitBtn.innerHTML = '<span class="loading-spinner me-2"></span>分析中...';
            submitBtn.disabled = true;
        });
        //计算列表长度
        function getListLength(list) {
            return list.length;
        }
        //计算指定元素在列表中的位置
        function findFirstPosition(list, element) {
            return list.indexOf(element);
        }
    </script>
</body>
</html> 